import Vue from "vue";
import store from "./store";
import api from "./api/install";
import utils from "@/utils/utils";
import i18n from "./i18n/i18n";
import "./utils/rem";
import "@/icons/index";
import "./icons";
// import md5 from "js-md5";
import VideoPlayer from "vue-video-player";
window.videojs = VideoPlayer.videojs;
Vue.use(VideoPlayer);

import niceLoading from "@/components/common/loading/Index.vue";
import niceEmpty from "@/components/common/empty/Index.vue";

import App from "./App.vue";
import router from "./router";
import {
  Avatar,
  Dropdown,
  DropdownMenu,
  DropdownItem,
  Form,
  FormItem,
  Input,
  Button,
  Image,
  Icon,
  InfiniteScroll,
  Pagination,
  MessageBox,
  Message,
  Notification,
  Table,
  TableColumn,
  Popover,
  Tooltip,
  Slider,
  Loading,
  Dialog,
  Container,
  Header,
  Aside,
  Main,
  Footer,
  Row,
  Col,
  Menu,
  Submenu,
  MenuItem,
  Tabs,
  TabPane,
  Carousel,
  CarouselItem,
  Breadcrumb,
  BreadcrumbItem,
  Backtop,
  Drawer,
  Checkbox,
  CheckboxGroup,
  Select,
  Option,
  Radio,
  RadioGroup,
  DatePicker,
  Collapse,
  CollapseItem,
} from "element-ui";
Vue.use(api);
// Vue.use(APlayer, {
//   defaultCover: "https://github.com/u3u.png",
//   productionTip: true,
// });
Vue.use(Avatar)
  .use(Image)
  .use(Icon)
  .use(Pagination)
  .use(InfiniteScroll)
  .use(Dropdown)
  .use(DropdownMenu)
  .use(DropdownItem)
  .use(Form)
  .use(FormItem)
  .use(Input)
  .use(Button)
  .use(Table)
  .use(TableColumn)
  .use(Popover)
  .use(Tooltip)
  .use(Slider)
  .use(Loading)
  .use(Dialog)
  .use(Container)
  .use(Header)
  .use(Aside)
  .use(Main)
  .use(Footer)
  .use(Row)
  .use(Col)
  .use(Menu)
  .use(Submenu)
  .use(MenuItem)
  .use(Tabs)
  .use(TabPane)
  .use(Carousel)
  .use(CarouselItem)
  .use(Breadcrumb)
  .use(BreadcrumbItem)
  .use(Backtop)
  .use(Drawer)
  .use(Checkbox)
  .use(CheckboxGroup)
  .use(Select)
  .use(Option)
  .use(Radio)
  .use(RadioGroup)
  .use(DatePicker)
  .use(Collapse)
  .use(CollapseItem);

Vue.config.productionTip = false;
Vue.prototype.utils = utils;

Vue.prototype.$msgbox = MessageBox;
Vue.prototype.$alert = MessageBox.alert;
Vue.prototype.$confirm = MessageBox.confirm;
Vue.prototype.$prompt = MessageBox.prompt;
Vue.prototype.$notify = Notification;
Vue.prototype.$message = Message;
// Vue.prototype.$md5 = md5;
Vue.component("niceLoading", niceLoading);
Vue.component("niceEmpty", niceEmpty);
// button阻止重复点击
Vue.directive("preventReClick", {
  inserted(el, binding) {
    el.addEventListener("click", () => {
      if (!el.disabled) {
        el.disabled = true;
        setTimeout(() => {
          el.disabled = false;
        }, binding.value || 3000);
      }
    });
  },
});
//单个修改标题
Vue.directive("title", {
  inserted(el) {
    document.title = el.dataset.title;
  },
});

new Vue({
  router,
  store,
  i18n,
  render: (h) => h(App),
}).$mount("#app");
